import request from '@/utils/request'

//获取SPU列表数据的接口
//  /admin/product/{page}/{limit}   get   page当前第几页 limit每页显示多少条数据 category3Id三级分类id
export const reqSpuList=(page,limit,category3Id)=>request({
    url:`/admin/product/${page}/${limit} `,
    method:'get',
    params:{category3Id},
})

//获取SPU信息
///admin/product/getSpuById/{spuId}   get
export const reqSpu=spuId=>request.get(`/admin/product/getSpuById/${spuId}`)

//获取品牌的信息
///admin/product/baseTrademark/getTrademarkList  get
export const reqTradeMarkList=()=>request.get(`/admin/product/baseTrademark/getTrademarkList`)


//获取SPU图标的接口
///admin/product/spuImageList/{spuId}  get
export const reqSpuImageList=spuId=>request.get(`/admin/product/spuImageList/${spuId}`)

// 删除SPU /admin/product/deleteSpu/{spuId} delete
export const reqDeleteSpu=spuId=>request.delete(`/admin/product/deleteSpu/${spuId}`)

//获取平台全部销售属性
//GET /admin/product/baseSaleAttrList  
export const reqBaseSaleAttrList=()=>request.get('/admin/product/baseSaleAttrList')

// 修改SPU||添加SPU：对于修改或者添加，携带给服务器参数大致一样的，唯一的区别就是携带的参数是否带id
export const reqAddOrUpdateSpu=(spuInfo)=>{
    // 修改
    if(spuInfo.id){
        return request({url:`/admin/product/updateSpuInfo`,method:'post',data:spuInfo})
    }else{
    // 添加
        return request({url:`/admin/product/saveSpuInfo`,method:'post',data:spuInfo})
    }
}


// Sku页面

// 获取图片数据
// /admin/product/spuImageList/{spuId}  get
export const reqGetImages=spuId=>request.get(`/admin/product/spuImageList/${spuId}`)

// 获取销售属性的数据
// /admin/product/spuSaleAttrList/{spuId}  get
export const reqSpuSaleAttr=spuId=>request.get(`/admin/product/spuSaleAttrList/${spuId}`)

// 获取平台属性的数据
// /GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id} 
export const reqAttrInfoList=({category1Id,category2Id,category3Id})=>request.get(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)

//添加SKU
// /admin/product/saveSkuInfo  post
export const reqAddSku=skuInfo=>request({url:'/admin/product/saveSkuInfo',method:'post',data:skuInfo})

//获取SKU列表数据的接口
//GET /admin/product/findBySpuId/{spuId}  

export const reqGetSkuList=spuId=>request.get(`/admin/product/findBySpuId/${spuId}`)















